Interface WebServerProvider
- All Known Implementing Classes:
GrizzlyHttpServerProvider
,JdkHttpServerProvider
,SimpleHttpServerProvider
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 Summary
Modifier and TypeMethodDescription<T extends WebServer>
TcreateServer
(Class<T> type, Application application, SeBootstrap.Configuration configuration) Creates a server of a given type which runs the given application using the given bootstrap configuration.<T extends WebServer>
TcreateServer
(Class<T> type, Class<? extends Application> applicationClass, SeBootstrap.Configuration configuration) Creates a server of a given type which runs the given application using the given bootstrap configuration.static <T extends WebServer>
booleanisSupportedWebServer
(Class<? extends WebServer> supportedType, Class<T> userType, SeBootstrap.Configuration configuration) Utility function that matchesWebServerProvider
supported type with the user type passed either asServerProperties.WEBSERVER_CLASS
property (higher priority) or by theuserType
argument (lower priority).
-
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 leastWebServer
.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 requestedtype
. - 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 leastWebServer
.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 requestedtype
. - 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 matchesWebServerProvider
supported type with the user type passed either asServerProperties.WEBSERVER_CLASS
property (higher priority) or by theuserType
argument (lower priority).- Type Parameters:
T
- TheWebServer
subtype- Parameters:
supportedType
- The type supported by theWebServerProvider
implementationuserType
- The user type passed in by the user, usuallyWebServer
class.configuration
- The configuration to checkServerProperties.WEBSERVER_CLASS
property- Returns:
-