Class KristenHttpServer

    • Constructor Detail

      • KristenHttpServer

        public KristenHttpServer​(KristenHttpServerParameters parameters)
                          throws com.kristensoft.kdc.license.runtime.LicenseException,
                                 KristenCommsException
        Creates an HTTP server using the specified parameters.

        The server is started automatically if automatic startup is enabled in the supplied parameters.

        Parameters:
        parameters - the parameters used to configure the HTTP server
        Throws:
        IllegalArgumentException - if parameters is null
        com.kristensoft.kdc.license.runtime.LicenseException - if the server cannot be created due to a licensing error
        KristenCommsException - if a KDC communications error occurs
        See Also:
        KristenHttpServerParameters
    • Method Detail

      • getKristenHttpServerParameters

        public KristenHttpServerParameters getKristenHttpServerParameters()
        Returns the parameters used to configure this HTTP server.
        Returns:
        the HTTP server parameters
      • run

        public void run()
        Starts this HTTP server.
        Specified by:
        run in interface Runnable
        Specified by:
        run in class Server
      • start

        public void start()
        Starts this HTTP server.

        Creates the underlying HTTP server, configures its request executor and default context, and begins accepting HTTP requests. If the server is already started, this method returns without taking further action.

        Overrides:
        start in class Server
      • clear

        public void clear()
        Removes all pending requests from the HTTP server request queue.
      • stop

        public void stop​(int delay)
        Stops this HTTP server.

        The specified delay allows current HTTP exchanges time to complete before the underlying server is stopped. If the server is not started, this method returns without taking further action.

        Parameters:
        delay - the maximum time, in seconds, to wait for current exchanges to complete
        Throws:
        IllegalArgumentException - if delay is less than zero
        IllegalStateException - if the underlying HTTP server is not available
      • createContext

        public com.sun.net.httpserver.HttpContext createContext​(String path)
        Creates an HTTP context for the specified path.

        Agents received through the context are processed using the APIs configured for this server.

        Parameters:
        path - the path for the HTTP context
        Returns:
        the created HTTP context
        Throws:
        IllegalStateException - if the HTTP server is not started or the underlying HTTP server is not available
        IllegalArgumentException - if path is null
      • deleteContext

        public void deleteContext​(com.sun.net.httpserver.HttpContext context)
        Removes the specified HTTP context from this server.
        Parameters:
        context - the HTTP context to remove
        Throws:
        IllegalStateException - if the HTTP server is not started or the underlying HTTP server is not available
        IllegalArgumentException - if context is null
      • deleteContext

        public void deleteContext​(String path)
        Removes the HTTP context associated with the specified path from this server.
        Parameters:
        path - the path of the HTTP context to remove
        Throws:
        IllegalStateException - if the HTTP server is not started or the underlying HTTP server is not available
        IllegalArgumentException - if path is null
      • getDefaultContext

        public com.sun.net.httpserver.HttpContext getDefaultContext()
        Returns the default HTTP context for this server.
        Returns:
        the default HTTP context, or null if the server has not been started
      • getLocalAddress

        public InetSocketAddress getLocalAddress()
        Returns the local address of this HTTP server.
        Returns:
        the local server address, or null if the underlying HTTP server has not been created
      • close

        public void close()
        Closes this HTTP server, allowing up to one second for current HTTP exchanges to complete.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in class Server
      • halt

        public void halt()
        Halts this HTTP server by closing it.
        Overrides:
        halt in class Server
      • isRunning

        public boolean isRunning()
        Determines whether this communication entity is currently running.
        Returns:
        true if this communication entity is running; false otherwise
      • flushMetrics

        public void flushMetrics()
        Flushes the accumulated latency metrics for this communication entity.

        This method may be used to report any currently accumulated metrics without waiting for the configured latency reporting interval.

      • getAgentSerializer

        public AgentSerializer getAgentSerializer()
        Returns the agent serializer used by this communication entity.

        The serializer may be used to inspect or modify serialization settings at runtime, including compression and encryption settings.

        Returns:
        the agent serializer used by this communication entity