- All Known Implementing Classes:
EPollTransport,IOUringTransport
WebServer interface.
A Transport encompasses certain parts of the inner
workings of a given WebServer implementation that
simultaneously should not be exposed but need to be configurable.
A WebServer implementation may call createTransportArtifact(Class, String, ServerConfiguration)
during startup, and then never again, passing non-null
arguments. Only one call per combination of artifactType
and artifactName is permitted.
It is not expected or required that implementations of this interface be safe for concurrent use by multiple threads.
-
Method Summary
Modifier and TypeMethodDescription<T> Optional<T>createTransportArtifact(Class<T> type, String name, ServerConfiguration config) Creates and returns a suitable transport artifact, if one can be created or is available, and an emptyOptionalotherwise.booleanisAvailableFor(WebServer webserver)
-
Method Details
-
isAvailableFor
Returnstrueif thisTransportimplementation is available for use by the givenWebServerimplementation;falseotherwise.Implementations of this method must be idempotent and deterministic.
WebServerimplementations normally call this method, supplying themselves, and interpret its return value before performing any invocation ofcreateTransportArtifact(Class, String, ServerConfiguration).If a given
Transportimplementation returnsfalsefrom its implementation of this method, then a givenWebServerimplementation is permitted to discard it and use anotherTransportimplementation instead.The
WebServerpassed to this method is in a deliberately undefined state. Most notably, it has not yet been configured, and it is in the process of being constructed. MostTransportimplementations should either not use this parameter at all or, for example, should only test it to see if it is an implementation ofWebServerthat they support. -
createTransportArtifact
Creates and returns a suitable transport artifact, if one can be created or is available, and an emptyOptionalotherwise.A transport artifact is a deliberately opaque item that is defined by a particular
WebServerimplementation that is needed at startup time. A transport artifact has aString-typed name and aClass-typed type. AWebServerimplementation may call this method only after having receivedtruefrom an invocation ofisAvailableFor(WebServer).A
WebServerimplementation must not call this method more than once per combination oftypeandnameor undefined behavior will result.No further specifications of any kind are made regarding the behavior of any implementation of this method. Specifically, an implementation may create a new artifact, or return a cached one.
Implementations of this method are called while a
WebServerimplementation is in the process of being constructed and while it is in a deliberately undefined state.- Type Parameters:
T- the type of the transport artifact- Parameters:
type- aClassthat can help to identify the kind of artifact to be returnedname- theWebServer-implementation-specific name of a specific transport artifact of the given type that should be returnedconfig- the finalizedServerConfigurationin effect during construction of theWebServerimplementation- Returns:
- an
Optional, possibly empty, representing the desired transport artifact
-