T
- The type of builder used by this factory.public abstract class AbstractGrpcServerFactory<T extends ServerBuilder<T>> extends Object implements GrpcServerFactory
Modifier and Type | Field and Description |
---|---|
protected GrpcServerProperties |
properties |
protected List<GrpcServerConfigurer> |
serverConfigurers |
Constructor and Description |
---|
AbstractGrpcServerFactory(GrpcServerProperties properties,
List<GrpcServerConfigurer> serverConfigurers)
Creates a new server factory with the given properties.
|
Modifier and Type | Method and Description |
---|---|
void |
addService(GrpcServiceDefinition service)
Adds the given grpc service definition to this factory.
|
protected void |
configure(T builder)
Configures the given server builder.
|
protected void |
configureLimits(T builder)
Configures limits such as max message sizes that should be used by the server.
|
protected void |
configureSecurity(T builder)
Configures the security options that should be used by the server.
|
protected void |
configureServices(T builder)
Configures the services that should be served by the server.
|
Server |
createServer()
Creates a new grpc server with the stored options.
|
void |
destroy()
Destroys this factory.
|
String |
getAddress()
Gets the IP address the created server will be bound to.
|
int |
getPort()
Gets the local port the created server will use to listen to requests.
|
protected abstract T |
newServerBuilder()
Creates a new server builder.
|
protected File |
toCheckedFile(String context,
String path)
Converts the given path to a file.
|
protected final GrpcServerProperties properties
protected final List<GrpcServerConfigurer> serverConfigurers
public AbstractGrpcServerFactory(GrpcServerProperties properties, List<GrpcServerConfigurer> serverConfigurers)
properties
- The properties used to configure the server.serverConfigurers
- The server configurers to use. Can be empty.public Server createServer()
GrpcServerFactory
createServer
in interface GrpcServerFactory
protected abstract T newServerBuilder()
protected void configure(T builder)
GrpcServerConfigurer
instead.builder
- The server builder to configure.protected void configureServices(T builder)
builder
- The server builder to configure.protected void configureSecurity(T builder)
builder
- The server builder to configure.protected File toCheckedFile(String context, String path)
context
- The context for what the file is used. This value will be used in case of exceptions.path
- The path of the file to use.protected void configureLimits(T builder)
builder
- The server builder to configure.public String getAddress()
GrpcServerFactory
getAddress
in interface GrpcServerFactory
public int getPort()
GrpcServerFactory
getPort
in interface GrpcServerFactory
public void addService(GrpcServiceDefinition service)
GrpcServerFactory
Note: Adding a service does not effect servers that have already been created.
addService
in interface GrpcServerFactory
service
- The service to add to the grpc server.public void destroy()
GrpcServerFactory
destroy
in interface GrpcServerFactory