Package io.grpc.servlet
Class 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-box
GrpcServlet
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
(package private) int
private ScheduledExecutorService
private final ServerImplBuilder
(package private) List
<? extends ServerStreamTracer.Factory> private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a gRPC server that can run as a servlet.private ServerTransportListener
Creates aGrpcServlet
.Creates aServletAdapter
.(package private) InternalServer
buildTransportServers
(List<? extends ServerStreamTracer.Factory> streamTracerFactories) protected ServerBuilder
<?> delegate()
Returns the delegatedServerBuilder
.maxInboundMessageSize
(int bytes) Sets the maximum message size allowed to be received on the server.scheduledExecutorService
(ScheduledExecutorService scheduler) Provides a custom scheduled executor service to the server builder.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
-
Field Details
-
streamTracerFactories
List<? extends ServerStreamTracer.Factory> streamTracerFactories -
maxInboundMessageSize
int maxInboundMessageSize -
serverImplBuilder
-
scheduler
-
internalCaller
private boolean internalCaller -
usingCustomScheduler
private boolean usingCustomScheduler -
internalServer
-
-
Constructor Details
-
ServletServerBuilder
public ServletServerBuilder()
-
-
Method Details
-
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
Creates aServletAdapter
. -
buildServlet
Creates aGrpcServlet
. -
buildAndStart
-
buildTransportServers
InternalServer buildTransportServers(List<? extends ServerStreamTracer.Factory> streamTracerFactories) -
delegate
Description copied from class:ForwardingServerBuilder
Returns the delegatedServerBuilder
.- Specified by:
delegate
in classForwardingServerBuilder<ServletServerBuilder>
-
useTransportSecurity
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
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
Provides a custom scheduled executor service to the server builder.- Returns:
- this
-