Constructor and Description |
---|
ServerBuilder() |
Modifier and Type | Method and Description |
---|---|
abstract T |
addService(BindableService bindableService)
Adds a service implementation to the handler registry.
|
abstract T |
addService(ServerServiceDefinition service)
Adds a service implementation to the handler registry.
|
abstract Server |
build()
Builds a server using the given parameters.
|
abstract T |
compressorRegistry(CompressorRegistry registry)
Set the compression registry for use in the channel.
|
abstract T |
decompressorRegistry(DecompressorRegistry registry)
Set the decompression registry for use in the channel.
|
abstract T |
directExecutor()
Execute application code directly in the transport thread.
|
abstract T |
executor(Executor executor)
Provides a custom executor.
|
abstract T |
fallbackHandlerRegistry(HandlerRegistry fallbackRegistry)
Sets a fallback handler registry that will be looked up in if a method is not found in the
primary registry.
|
static ServerBuilder<?> |
forPort(int port) |
abstract T |
useTransportSecurity(File certChain,
File privateKey)
Makes the server use TLS.
|
public static ServerBuilder<?> forPort(int port)
public abstract T directExecutor()
Depending on the underlying transport, using a direct executor may lead to substantial performance improvements. However, it also requires the application to not block under any circumstances.
Calling this method is semantically equivalent to calling executor(Executor)
and
passing in a direct executor. However, this is the preferred way as it may allow the transport
to perform special optimizations.
public abstract T executor(@Nullable Executor 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 abstract T addService(ServerServiceDefinition service)
service
- ServerServiceDefinition objectpublic abstract T addService(BindableService bindableService)
bindableService
- BindableService object@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/933") public abstract T fallbackHandlerRegistry(@Nullable HandlerRegistry fallbackRegistry)
public abstract T useTransportSecurity(File certChain, File privateKey)
certChain
- file containing the full certificate chainprivateKey
- file containing the private key@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1704") public abstract T decompressorRegistry(@Nullable DecompressorRegistry registry)
DecompressorRegistry.getDefaultInstance
.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1704") public abstract T compressorRegistry(@Nullable CompressorRegistry registry)
CompressorRegistry.getDefaultInstance
.public abstract Server build()
The returned service will not been started or be bound a port. You will need to start it
with Server.start()
.