Interface WebServerProvider


  • @Contract
    @ConstrainedTo(SERVER)
    public interface WebServerProvider
    Service-provider interface for creating server instances. If supported by the provider, a server instance of the requested Java type will be created.

    The created server uses an internally created Container which is responsible for listening on a communication channel provided by the server for new client requests, dispatching these requests to the registered Jersey application handler using the handler's handle(requestContext) method and sending the responses provided by the application back to the client.

    A provider shall support a one-to-one mapping between a type, provided the type is not Object. A provider may also support mapping of sub-types of a type (provided the type is not Object). It is expected that each provider supports mapping for distinct set of types and subtypes so that different providers do not conflict with each other. In addition, a provider SHOULD support the super type WebServer to participate in auto-selection of providers (in this case the first supporting provider found is used).

    An implementation can identify itself by placing a Java service provider configuration file (if not already present) - org.glassfish.jersey.server.spi.WebServerProvider - in the resource directory META-INF/services, and adding the fully qualified service-provider-class of the implementation in the file.

    Since:
    3.1.0
    Author:
    Markus KARG (markus@headcrashing.eu)
    • Method Detail

      • createServer

        <T extends WebServer> T createServer​(Class<T> type,
                                             jakarta.ws.rs.core.Application application,
                                             JerseySeBootstrapConfiguration configuration)
                                      throws jakarta.ws.rs.ProcessingException
        Creates a server of a given type which runs the given application using the given bootstrap configuration.
        Type Parameters:
        T - the type of the web server.
        Parameters:
        type - the type of the web server. Providers SHOULD support at least WebServer.
        application - The application to host.
        configuration - The configuration (host, port, etc.) to be used for bootstrapping.
        Returns:
        the server, otherwise null if the provider does not support the requested type.
        Throws:
        jakarta.ws.rs.ProcessingException - if there is an error creating the server.
      • createServer

        <T extends WebServer> T createServer​(Class<T> type,
                                             Class<? extends jakarta.ws.rs.core.Application> applicationClass,
                                             JerseySeBootstrapConfiguration configuration)
                                      throws jakarta.ws.rs.ProcessingException
        Creates a server of a given type which runs the given application using the given bootstrap configuration.
        Type Parameters:
        T - the type of the web server.
        Parameters:
        type - the type of the web server. Providers SHOULD support at least WebServer.
        applicationClass - The class of application to host.
        configuration - The configuration (host, port, etc.) to be used for bootstrapping.
        Returns:
        the server, otherwise null if the provider does not support the requested type.
        Throws:
        jakarta.ws.rs.ProcessingException - if there is an error creating the server.