BuilderT
- The concrete type for this builder.public abstract class AbstractServerBuilder<BuilderT extends AbstractServerBuilder<BuilderT>> extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractServerBuilder.ServerEssentials |
Modifier | Constructor and Description |
---|---|
protected |
AbstractServerBuilder()
Constructs with a MutableHandlerRegistry created internally.
|
protected |
AbstractServerBuilder(HandlerRegistry registry)
Constructs using a given handler registry.
|
Modifier and Type | Method and Description |
---|---|
BuilderT |
addService(ServerServiceDefinition service)
Adds a service implementation to the handler registry.
|
ServerImpl |
build()
Builds a server using the given parameters.
|
protected abstract AbstractServerBuilder.ServerEssentials |
buildEssentials() |
BuilderT |
executor(ExecutorService executor)
Provides a custom executor.
|
protected AbstractServerBuilder(HandlerRegistry registry)
protected AbstractServerBuilder()
public final BuilderT executor(ExecutorService executor)
It's an optional parameter. If the user has not provided an executor when the server is built, the builder will use a static cached thread pool.
The server won't take ownership of the given executor. It's caller's responsibility to shut down the executor when it's desired.
public final BuilderT addService(ServerServiceDefinition service)
This is supported only if the user didn't provide a handler registry, or the provided one is
a MutableHandlerRegistry
. Otherwise it throws an UnsupportedOperationException.
public ServerImpl build()
The returned service will not been started or be bound a port. You will need to start it
with ServerImpl.start()
.
protected abstract AbstractServerBuilder.ServerEssentials buildEssentials()