-
- All Known Implementing Classes:
EPollTransport
,IOUringTransport
public interface Transport
A very abstract notion of a transport for a particular implementation of theWebServer
interface.A
Transport
encompasses certain parts of the inner workings of a givenWebServer
implementation that simultaneously should not be exposed but need to be configurable.A
WebServer
implementation may callcreateTransportArtifact(Class, String, ServerConfiguration)
during startup, and then never again, passing non-null
arguments. Only one call per combination ofartifactType
andartifactName
is permitted.It is not expected or required that implementations of this interface be safe for concurrent use by multiple threads.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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 emptyOptional
otherwise.boolean
isAvailableFor(WebServer webserver)
-
-
-
Method Detail
-
isAvailableFor
boolean isAvailableFor(WebServer webserver)
Returnstrue
if thisTransport
implementation is available for use by the givenWebServer
implementation;false
otherwise.Implementations of this method must be idempotent and deterministic.
WebServer
implementations normally call this method, supplying themselves, and interpret its return value before performing any invocation ofcreateTransportArtifact(Class, String, ServerConfiguration)
.If a given
Transport
implementation returnsfalse
from its implementation of this method, then a givenWebServer
implementation is permitted to discard it and use anotherTransport
implementation instead.The
WebServer
passed 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. MostTransport
implementations should either not use this parameter at all or, for example, should only test it to see if it is an implementation ofWebServer
that they support.
-
createTransportArtifact
<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 emptyOptional
otherwise.A transport artifact is a deliberately opaque item that is defined by a particular
WebServer
implementation that is needed at startup time. A transport artifact has aString
-typed name and aClass
-typed type. AWebServer
implementation may call this method only after having receivedtrue
from an invocation ofisAvailableFor(WebServer)
.A
WebServer
implementation must not call this method more than once per combination oftype
andname
or 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
WebServer
implementation 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
- aClass
that 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 finalizedServerConfiguration
in effect during construction of theWebServer
implementation- Returns:
- an
Optional
, possibly empty, representing the desired transport artifact
-
-