Annotation Type GrpcClient


@Retention(CLASS) @Target(TYPE) public @interface GrpcClient

Marks an interface as a gRPC client that the build-time annotation processor wires up to a generated implementation: gRPC-Web in an application, native gRPC over HTTP/2 in a backend. Each abstract method must carry an Rpc annotation naming the gRPC method, and at most one non-callback parameter -- the request message, a @ProtoMessage-annotated POJO. In an application the final parameter is an OnComplete<Response<ResponseMessage>> callback; in a backend methods are blocking and may stream (see the backend's com.codename1.backend.grpc package).

The fully qualified service path defaults to <value()>/<methodName> -- for example helloworld.Greeter/SayHello. Override per-method via Rpc.service() when the service path needs to differ from the interface-level default.

The processor emits a <SimpleName>Impl class in generated-sources and registers it with the runtime's client registry (com.codename1.io.grpc.GrpcClients in an application) so the interface's static T of(String baseUrl) factory can return an instance without the project source referencing the impl directly. Mirrors com.codename1.annotations.rest.RestClient.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Fully qualified gRPC service path (without leading slash), e.g.
  • Element Details

    • value

      String value
      Fully qualified gRPC service path (without leading slash), e.g. helloworld.Greeter. Combined with each method's Rpc.value() to form the request URI segment /<service>/<method> appended to the baseUrl. Empty string means each method must specify the full service path via Rpc.service().
      Default:
      ""