Class AbstractServiceBuilder
java.lang.Object
io.helidon.microprofile.grpc.core.AbstractServiceBuilder
- Direct Known Subclasses:
GrpcServiceBuilder
A base class for gRPC service and client descriptor builders.
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractServiceBuilder
(Class<?> serviceClass, Supplier<?> instanceSupplier) Create a new introspection modeller for a given gRPC service class. -
Method Summary
Modifier and TypeMethodDescriptionprotected Class
<?> Obtain the actual annotated class.protected void
Verify that there are no non-public annotated methods.protected static Supplier
<?> createInstanceSupplier
(Class<?> cls) Create the service instance supplier.static String
determineMethodName
(AnnotatedMethod method, Grpc.GrpcMethod annotation) Determine the name to use from the method.protected String
determineServiceName
(Class<?> annotatedClass) Determine the name of the gRPC service.getAllDeclaredMethods
(Class<?> clazz) Obtain a list of all of the methods declared on the service class.protected MarshallerSupplier
Obtain theMarshallerSupplier
to use.protected List
<MethodHandlerSupplier> Obtain the list of method handler suppliers.protected Supplier
<?> Obtain the service instance supplier.boolean
Determine whether this modeller contains an annotated service.protected Class
<?> Obtain the service class.
-
Constructor Details
-
AbstractServiceBuilder
Create a new introspection modeller for a given gRPC service class.- Parameters:
serviceClass
- gRPC service (handler) class.instanceSupplier
- the target instanceSupplier to call gRPC handler methods on- Throws:
NullPointerException
- if the service or instanceSupplier parameters are null
-
-
Method Details
-
isAnnotatedService
public boolean isAnnotatedService()Determine whether this modeller contains an annotated service.- Returns:
true
if this modeller contains an annotated service
-
determineMethodName
Determine the name to use from the method.If the method is annotated with
Grpc.GrpcMethod
or an annotation that is annotated withGrpc.GrpcMethod
, then attempt to determine the method name from the annotation. If unable, use the actual method name.- Parameters:
method
- the annotated methodannotation
- the method type annotation- Returns:
- the value to use for the method name
-
serviceClass
Obtain the service class.- Returns:
- the service class
-
annotatedServiceClass
Obtain the actual annotated class.- Returns:
- the actual annotated class
-
getMarshallerSupplier
Obtain theMarshallerSupplier
to use.The
MarshallerSupplier
will be determined by theGrpc.GrpcMarshaller
annotation if it is present otherwise the default supplier will be returned.- Returns:
- the
MarshallerSupplier
to use
-
createInstanceSupplier
Create the service instance supplier.- Parameters:
cls
- the service class- Returns:
- the service instance supplier
-
checkForNonPublicMethodIssues
protected void checkForNonPublicMethodIssues()Verify that there are no non-public annotated methods. -
handlerSuppliers
Obtain the list of method handler suppliers.- Returns:
- the list of method handler suppliers
-
instanceSupplier
Obtain the service instance supplier.- Returns:
- the service instance supplier
-
getAllDeclaredMethods
Obtain a list of all of the methods declared on the service class.- Parameters:
clazz
- the service class- Returns:
- a list of all of the methods declared on the service class
-
determineServiceName
Determine the name of the gRPC service.If the class is annotated with
Grpc.GrpcService
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.- Parameters:
annotatedClass
- the annotated class- Returns:
- the name of the gRPC service
-