Class AbstractServiceBuilder

Direct Known Subclasses:

public abstract class AbstractServiceBuilder extends Object
A base class for gRPC service and client descriptor builders.
  • Constructor Details

    • AbstractServiceBuilder

      protected AbstractServiceBuilder(Class<?> serviceClass, Supplier<?> instance)
      Create a new introspection modeller for a given gRPC service class.
      serviceClass - gRPC service (handler) class.
      instance - the target instance to call gRPC handler methods on
      NullPointerException - if the service or instance parameters are null
  • Method Details

    • isAnnotatedService

      public boolean isAnnotatedService()
      Determine whether this modeller contains an annotated service.
      true if this modeller contains an annotated service
    • serviceClass

      protected Class<?> serviceClass()
      Obtain the service class.
      the service class
    • annotatedServiceClass

      protected Class<?> annotatedServiceClass()
      Obtain the actual annotated class.
      the actual annotated class
    • getMarshallerSupplier

      protected MarshallerSupplier getMarshallerSupplier()
      Obtain the MarshallerSupplier to use.

      The MarshallerSupplier will be determined by the GrpcMarshaller annotation if it is present otherwise the default supplier will be returned.

      the MarshallerSupplier to use
    • createInstanceSupplier

      protected static Supplier<?> createInstanceSupplier(Class<?> cls)
      Create the service instance supplier.
      cls - the service class
      the service instance supplier
    • checkForNonPublicMethodIssues

      protected void checkForNonPublicMethodIssues()
      Verify that there are no non-public annotated methods.
    • handlerSuppliers

      protected List<MethodHandlerSupplier> handlerSuppliers()
      Obtain the list of method handler suppliers.
      the list of method handler suppliers
    • instanceSupplier

      protected Supplier<?> instanceSupplier()
      Obtain the service instance supplier.
      the service instance supplier
    • getAllDeclaredMethods

      protected List<Method> getAllDeclaredMethods(Class<?> clazz)
      Obtain a list of all of the methods declared on the service class.
      clazz - the service class
      a list of all of the methods declared on the service class
    • determineServiceName

      protected String determineServiceName(Class<?> annotatedClass)
      Determine the name of the gRPC service.

      If the class is annotated with Grpc then the name value from the annotation is used as the service name. If the annotation has no name value or the annotation is not present the simple name of the class is used.

      annotatedClass - the annotated class
      the name of the gRPC service
    • determineMethodName

      public static String determineMethodName(AnnotatedMethod method, GrpcMethod annotation)
      Determine the name to use from the method.

      If the method is annotated with GrpcMethod then use the value of unless returns empty string, in which case use the actual method name.

      If the method is annotated with an annotation that has the meta-annotation GrpcMethod then use the value of that annotation's name() method. If that annotation does not have a name() method or the name() method return empty string then use the actual method name.

      method - the annotated method
      annotation - the method type annotation
      the value to use for the method name