Package io.grpc.servlet.jakarta
Class ServletServerBuilder
- java.lang.Object
-
- io.grpc.ServerBuilder<T>
-
- io.grpc.ForwardingServerBuilder<ServletServerBuilder>
-
- io.grpc.servlet.jakarta.ServletServerBuilder
-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/5066") @NotThreadSafe public final class ServletServerBuilder extends ForwardingServerBuilder<ServletServerBuilder>
Builder to build a gRPC server that can run as a servlet. This is for advanced custom settings. Normally, users should consider extending the out-of-boxGrpcServlet
directly instead.The API is experimental. The authors would like to know more about the real usecases. Users are welcome to provide feedback by commenting on the tracking issue.
-
-
Constructor Summary
Constructors Constructor Description ServletServerBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Server
build()
Builds a gRPC server that can run as a servlet.GrpcServlet
buildServlet()
Creates aGrpcServlet
.ServletAdapter
buildServletAdapter()
Creates aServletAdapter
.protected ServerBuilder<?>
delegate()
Returns the delegatedServerBuilder
.ServletServerBuilder
maxInboundMessageSize(int bytes)
Sets the maximum message size allowed to be received on the server.ServletServerBuilder
scheduledExecutorService(ScheduledExecutorService scheduler)
Provides a custom scheduled executor service to the server builder.ServletServerBuilder
useTransportSecurity(File certChain, File privateKey)
ThrowsUnsupportedOperationException
.-
Methods inherited from class io.grpc.ForwardingServerBuilder
addService, addService, addStreamTracerFactory, addTransportFilter, callExecutor, compressorRegistry, decompressorRegistry, directExecutor, executor, fallbackHandlerRegistry, forPort, handshakeTimeout, intercept, keepAliveTime, keepAliveTimeout, maxConnectionAge, maxConnectionAgeGrace, maxConnectionIdle, maxInboundMetadataSize, permitKeepAliveTime, permitKeepAliveWithoutCalls, setBinaryLog, toString, useTransportSecurity
-
Methods inherited from class io.grpc.ServerBuilder
addServices
-
-
-
-
Method Detail
-
build
public Server build()
Builds a gRPC server that can run as a servlet.The returned server will not be started or bound to a port.
Users should not call this method directly. Instead users should call
buildServletAdapter()
which internally will callbuild()
andstart()
appropriately.- Overrides:
build
in classForwardingServerBuilder<ServletServerBuilder>
- Returns:
- a new Server
- Throws:
IllegalStateException
- if this method is called by users directly
-
buildServletAdapter
public ServletAdapter buildServletAdapter()
Creates aServletAdapter
.
-
buildServlet
public GrpcServlet buildServlet()
Creates aGrpcServlet
.
-
delegate
@Internal protected ServerBuilder<?> delegate()
Description copied from class:ForwardingServerBuilder
Returns the delegatedServerBuilder
.- Specified by:
delegate
in classForwardingServerBuilder<ServletServerBuilder>
-
useTransportSecurity
public ServletServerBuilder useTransportSecurity(File certChain, File privateKey)
ThrowsUnsupportedOperationException
. TLS should be configured by the servlet container.- Overrides:
useTransportSecurity
in classForwardingServerBuilder<ServletServerBuilder>
- Parameters:
certChain
- file containing the full certificate chainprivateKey
- file containing the private key- Returns:
- this
-
maxInboundMessageSize
public ServletServerBuilder maxInboundMessageSize(int bytes)
Description copied from class:ServerBuilder
Sets the maximum message size allowed to be received on the server. If not called, defaults to 4 MiB. The default provides protection to servers who haven't considered the possibility of receiving large messages while trying to be large enough to not be hit in normal usage.This method is advisory, and implementations may decide to not enforce this. Currently, the only known transport to not enforce this is
InProcessServer
.- Overrides:
maxInboundMessageSize
in classForwardingServerBuilder<ServletServerBuilder>
- Parameters:
bytes
- the maximum number of bytes a single message can be.- Returns:
- this
-
scheduledExecutorService
public ServletServerBuilder scheduledExecutorService(ScheduledExecutorService scheduler)
Provides a custom scheduled executor service to the server builder.- Returns:
- this
-
-