Interface WebServerProvider

All Known Implementing Classes:
GrizzlyHttpServerProvider, JdkHttpServerProvider, SimpleHttpServerProvider

@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 Details

    • createServer

      <T extends WebServer> T createServer(Class<T> type, Application application, SeBootstrap.Configuration configuration) throws 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:
      ProcessingException - if there is an error creating the server.
    • createServer

      <T extends WebServer> T createServer(Class<T> type, Class<? extends Application> applicationClass, SeBootstrap.Configuration configuration) throws 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:
      ProcessingException - if there is an error creating the server.
    • isSupportedWebServer

      static <T extends WebServer> boolean isSupportedWebServer(Class<? extends WebServer> supportedType, Class<T> userType, SeBootstrap.Configuration configuration)
      Utility function that matches WebServerProvider supported type with the user type passed either as ServerProperties.WEBSERVER_CLASS property (higher priority) or by the userType argument (lower priority).
      Type Parameters:
      T - The WebServer subtype
      Parameters:
      supportedType - The type supported by the WebServerProvider implementation
      userType - The user type passed in by the user, usually WebServer class.
      configuration - The configuration to check ServerProperties.WEBSERVER_CLASS property
      Returns: