Class HttpRestServerImpl

    • Field Detail

      • CONTEXT_PATH

        protected static final String CONTEXT_PATH
    • Constructor Detail

      • HttpRestServerImpl

        public HttpRestServerImpl​(org.refcodes.controlflow.ThreadingModel aThreadingModel)
        Constructs a HttpRestServerImpl. Use HttpRestServer.open(int) or similar to make it listen on your port. The provided ThreadingModel defines whether to use a single-threaded or a multi-threaded threading model. Threads are created as daemon threads. For more control on thread generation use the constructor HttpRestServerImpl(ExecutorService).
        Parameters:
        aThreadingModel - Specifies to either use a single-threaded threading model (no ExecutorService) or a multi-threaded threading model with a default ExecutorService as of ControlFlowUtility.createCachedExecutorService(boolean).
    • Method Detail

      • close

        public void close()
                   throws IOException
        Specified by:
        close in interface org.refcodes.component.Closable
        Throws:
        IOException
      • open

        public void open​(String aProtocol,
                         org.refcodes.security.KeyStoreDescriptor aStoreDescriptor,
                         int aPort,
                         int aMaxConnections)
                  throws IOException
        Opens the HTTPS sever connection (socket) at the given port allowing the given number of maximum connections at the same time using the provided HTTPS configuration parameters.
        Specified by:
        open in interface HttpRestServer
        Parameters:
        aProtocol - The protocol to use, e.g. "TLS".
        aStoreDescriptor - The store descriptor describing your KeyStore required for HTTPS.
        aPort - The port on which to listen for requests.
        aMaxConnections - The number of maximum connections at the same time.
        Throws:
        IOException - thrown in case something went wrong such as the port being already in use.
      • getConnectionStatus

        public org.refcodes.component.ConnectionStatus getConnectionStatus()
        Specified by:
        getConnectionStatus in interface org.refcodes.component.ConnectionStatusAccessor
      • onConnectionRequest

        public HttpRestServer onConnectionRequest​(org.refcodes.web.HttpsConnectionRequestObserver aObserver)
        Specified by:
        onConnectionRequest in interface org.refcodes.web.HttpsConnectionRequestObservable<HttpRestServer>
      • onBasicAuthRequest

        public HttpRestServer onBasicAuthRequest​(org.refcodes.web.BasicAuthObserver aBasicAuthObserver)
        Specified by:
        onBasicAuthRequest in interface org.refcodes.web.BasicAuthObservable<HttpRestServer>
      • setPort

        public void setPort​(int aPort)
        Specified by:
        setPort in interface org.refcodes.mixin.PortAccessor.PortMutator
      • getPort

        public int getPort()
        Specified by:
        getPort in interface org.refcodes.mixin.PortAccessor
      • setScheme

        public void setScheme​(org.refcodes.data.Scheme aScheme)
        Specified by:
        setScheme in interface org.refcodes.web.SchemeAccessor.SchemeMutator
      • getScheme

        public org.refcodes.data.Scheme getScheme()
        Specified by:
        getScheme in interface org.refcodes.web.SchemeAccessor
      • toProtocol

        public String toProtocol()
        Specified by:
        toProtocol in interface org.refcodes.web.SchemeAccessor
      • setProtocol

        public void setProtocol​(String aProtocol)
        Specified by:
        setProtocol in interface org.refcodes.web.SchemeAccessor.SchemeMutator
      • getKeyStoreDescriptor

        public org.refcodes.security.KeyStoreDescriptor getKeyStoreDescriptor()
        Specified by:
        getKeyStoreDescriptor in interface org.refcodes.security.KeyStoreDescriptorAccessor
      • setKeyStoreDescriptor

        public void setKeyStoreDescriptor​(org.refcodes.security.KeyStoreDescriptor aKeyStoreDescriptor)
        Specified by:
        setKeyStoreDescriptor in interface org.refcodes.security.KeyStoreDescriptorAccessor.KeyStoreDescriptorMutator
      • getMaxConnections

        public int getMaxConnections()
        Specified by:
        getMaxConnections in interface org.refcodes.io.MaxConnectionsAccessor
      • setMaxConnections

        public void setMaxConnections​(int aMaxConnections)
        Specified by:
        setMaxConnections in interface org.refcodes.io.MaxConnectionsAccessor.MaxConnectionsMutator
      • getHttpServer

        protected HttpServer getHttpServer()
        Gets the http server.
        Returns:
        the http server