Class AbstractGrpcServerFactory<T extends ServerBuilder<T>>
java.lang.Object
net.devh.boot.grpc.server.serverfactory.AbstractGrpcServerFactory<T>
- Type Parameters:
T- The type of builder used by this factory.
- All Implemented Interfaces:
GrpcServerFactory
- Direct Known Subclasses:
InProcessGrpcServerFactory,NettyGrpcServerFactory,ShadedNettyGrpcServerFactory
public abstract class AbstractGrpcServerFactory<T extends ServerBuilder<T>>
extends Object
implements GrpcServerFactory
Abstract factory for grpc servers.
- Since:
- 5/17/16
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GrpcServerPropertiesprotected final List<GrpcServerConfigurer> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractGrpcServerFactory(GrpcServerProperties properties, List<GrpcServerConfigurer> serverConfigurers) Creates a new server factory with the given properties. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddService(GrpcServiceDefinition service) Adds the given grpc service definition to this factory.protected voidConfigures the given server builder.protected voidconfigureConnectionLimits(T builder) Configures the keep alive options that should be used by the server.protected voidconfigureKeepAlive(T builder) Configures the keep alive options that should be used by the server.protected voidconfigureLimits(T builder) Configures limits such as max message sizes that should be used by the server.protected voidconfigureSecurity(T builder) Configures the security options that should be used by the server.protected voidconfigureServices(T builder) Configures the services that should be served by the server.Creates a new grpc server with the stored options.Gets the IP address the created server will be bound to.intgetPort()Gets the local port the created server will use to listen to requests.protected abstract TCreates a new server builder.
-
Field Details
-
properties
-
serverConfigurers
-
-
Constructor Details
-
AbstractGrpcServerFactory
protected AbstractGrpcServerFactory(GrpcServerProperties properties, List<GrpcServerConfigurer> serverConfigurers) Creates a new server factory with the given properties.- Parameters:
properties- The properties used to configure the server.serverConfigurers- The server configurers to use. Can be empty.
-
-
Method Details
-
createServer
Description copied from interface:GrpcServerFactoryCreates a new grpc server with the stored options. The entire lifecycle management of the server should be managed by the calling class. This includes starting and stopping the server.- Specified by:
createServerin interfaceGrpcServerFactory- Returns:
- The newly created grpc server.
-
newServerBuilder
Creates a new server builder.- Returns:
- The newly created server builder.
-
configure
Configures the given server builder. This method can be overwritten to add features that are not yet supported by this library or use aGrpcServerConfigurerinstead.- Parameters:
builder- The server builder to configure.
-
configureServices
Configures the services that should be served by the server.- Parameters:
builder- The server builder to configure.
-
configureKeepAlive
Configures the keep alive options that should be used by the server.- Parameters:
builder- The server builder to configure.
-
configureConnectionLimits
Configures the keep alive options that should be used by the server.- Parameters:
builder- The server builder to configure.
-
configureSecurity
Configures the security options that should be used by the server.- Parameters:
builder- The server builder to configure.
-
configureLimits
Configures limits such as max message sizes that should be used by the server.- Parameters:
builder- The server builder to configure.
-
getAddress
Description copied from interface:GrpcServerFactoryGets the IP address the created server will be bound to.- Specified by:
getAddressin interfaceGrpcServerFactory- Returns:
- The IP address the server will be bound to.
-
getPort
public int getPort()Description copied from interface:GrpcServerFactoryGets the local port the created server will use to listen to requests.- Specified by:
getPortin interfaceGrpcServerFactory- Returns:
- Gets the local port the server will use.
-
addService
Description copied from interface:GrpcServerFactoryAdds the given grpc service definition to this factory. The created server will serve the services described by these definitions.Note: Adding a service does not effect servers that have already been created.
- Specified by:
addServicein interfaceGrpcServerFactory- Parameters:
service- The service to add to the grpc server.
-