Interface HttpServerRegistry

  • All Implemented Interfaces:
    com.google.common.util.concurrent.Service

    
    public interface HttpServerRegistry
     implements Service
                        

    Simple HTTP server registry service.

    Creates HTTP servers and registers handlers for context paths. For proper shutdown of all servers stopAsync should be called.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract String initHttpServer(String schemeAndAuthority, boolean allowReuse) Creates an HTTP server at given URI.
      abstract String registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable() String mediaType, @Nullable() CommunicationLogContext communicationLogContext, HttpHandler handler) Registers a handler for HTTP requests destined to the given scheme, authority and context path.
      String registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable() String mediaType, @Nullable() CommunicationLogContext communicationLogContext, HttpHandler requestHandler, @Nullable() UnaryOperator<Void> postResponseHandler) Registers a handler for HTTP requests destined to the given scheme, authority and context path.
      abstract void unregisterContext(String schemeAndAuthority, String contextPath) Removes a handler for the given scheme, authority and context path.
      • Methods inherited from class com.google.common.util.concurrent.Service

        addListener, awaitRunning, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • initHttpServer

         abstract String initHttpServer(String schemeAndAuthority, boolean allowReuse)

        Creates an HTTP server at given URI.

        If there was no running HTTP server found under the passed scheme and authority, this function starts a new one. If the HTTP server supports both http and https schemes, the return value scheme will match the requested value.

        Parameters:
        schemeAndAuthority - the scheme and authority where to access the HTTP server.
        allowReuse - if the port given in schemeAndAuthority is 0, setting this to true will allow returning any already running server, while false will create a new server.
        Returns:

        the actual assigned URI of the HTTP server.

      • registerContext

        @Deprecated(forRemoval = true) abstract String registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable() String mediaType, @Nullable() CommunicationLogContext communicationLogContext, HttpHandler handler)

        Registers a handler for HTTP requests destined to the given scheme, authority and context path.

        If the HTTP server supports both http and https schemes, the return value scheme will match the requested value.

        Parameters:
        schemeAndAuthority - scheme and authority used to start a new or re-use an existing HTTP server.
        allowReuse - if the port given in schemeAndAuthority is 0, settings this to true will allow returning any already running server, while false will create a new server.
        contextPath - the context path where the given registry shall listen to.
        mediaType - the media type of the response the handler will produce.
        communicationLogContext - additional information made available in the communication log of the registered context.
        handler - the handler callback that is invoked on a request to the given context path.
        Returns:

        the actual full path of the HTTP server address the given handler listens to.

      • registerContext

         String registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable() String mediaType, @Nullable() CommunicationLogContext communicationLogContext, HttpHandler requestHandler, @Nullable() UnaryOperator<Void> postResponseHandler)

        Registers a handler for HTTP requests destined to the given scheme, authority and context path.

        If the HTTP server supports both http and https schemes, the return value scheme will match the requested value.

        Parameters:
        schemeAndAuthority - scheme and authority used to start a new or re-use an existing HTTP server.
        allowReuse - if the port given in schemeAndAuthority is 0, settings this to true will allow returning any already running server, while false will create a new server.
        contextPath - the context path where the given registry shall listen to.
        mediaType - the media type of the response the handler will produce.
        communicationLogContext - additional information made available in the communication log of the registered context.
        requestHandler - the handler callback that is invoked on a request to the given context path.
        postResponseHandler - optional callback that is invoked after the transmission of the response concluded
        Returns:

        the actual full path of the HTTP server address the given handler listens to.

      • unregisterContext

         abstract void unregisterContext(String schemeAndAuthority, String contextPath)

        Removes a handler for the given scheme, authority and context path.

        handle will not be called for any request destined to the corresponding handler. Requests to the corresponding are answered with an HTTP 404.

        Parameters:
        schemeAndAuthority - scheme and authority where the context shall be removed.
        contextPath - the context path to remove.