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 Details

  • 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

      public Server createServer()
      Description copied from interface: GrpcServerFactory
      Creates 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:
      createServer in interface GrpcServerFactory
      Returns:
      The newly created grpc server.
    • newServerBuilder

      protected abstract T newServerBuilder()
      Creates a new server builder.
      Returns:
      The newly created server builder.
    • configure

      protected void configure(T builder)
      Configures the given server builder. This method can be overwritten to add features that are not yet supported by this library or use a GrpcServerConfigurer instead.
      Parameters:
      builder - The server builder to configure.
    • configureServices

      protected void configureServices(T builder)
      Configures the services that should be served by the server.
      Parameters:
      builder - The server builder to configure.
    • configureKeepAlive

      protected void configureKeepAlive(T builder)
      Configures the keep alive options that should be used by the server.
      Parameters:
      builder - The server builder to configure.
    • configureConnectionLimits

      protected void configureConnectionLimits(T builder)
      Configures the keep alive options that should be used by the server.
      Parameters:
      builder - The server builder to configure.
    • configureSecurity

      protected void configureSecurity(T builder)
      Configures the security options that should be used by the server.
      Parameters:
      builder - The server builder to configure.
    • configureLimits

      protected void configureLimits(T builder)
      Configures limits such as max message sizes that should be used by the server.
      Parameters:
      builder - The server builder to configure.
    • getAddress

      public String getAddress()
      Description copied from interface: GrpcServerFactory
      Gets the IP address the created server will be bound to.
      Specified by:
      getAddress in interface GrpcServerFactory
      Returns:
      The IP address the server will be bound to.
    • getPort

      public int getPort()
      Description copied from interface: GrpcServerFactory
      Gets the local port the created server will use to listen to requests.
      Specified by:
      getPort in interface GrpcServerFactory
      Returns:
      Gets the local port the server will use.
    • addService

      public void addService(GrpcServiceDefinition service)
      Description copied from interface: GrpcServerFactory
      Adds 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:
      addService in interface GrpcServerFactory
      Parameters:
      service - The service to add to the grpc server.