Client and backend. Every class listed here is shared: the same code is compiled into your app and into your server. The package's page in the client API lists all of it, including any classes that exist only in the app.

package com.codename1.annotations.grpc

gRPC-Web client annotations. GrpcClient marks an interface as a gRPC client; Rpc binds each method to an RPC. ProtoMessage marks a POJO as a protobuf message; ProtoField tags each field; ProtoEnum marks an enum as protobuf-encoded.

The Codename One Maven plugin’s cn1:generate-grpc mojo emits these annotations from a user-supplied .proto file; the RestClient / ProtoMessage annotation processors then emit the implementation code at build time. End-to-end usage:

// generated by cn1:generate-grpc
@ProtoMessage
public final class HelloRequest {
    @ProtoField(tag = 1) public String name;
}

@ProtoMessage
public final class HelloReply {
    @ProtoField(tag = 1) public String message;
}

@GrpcClient("helloworld.Greeter")
public interface GreeterGrpc {
    @Rpc("SayHello")
    void sayHello(HelloRequest req,
                  OnComplete<Response<HelloReply>> callback);

    static GreeterGrpc of(String baseUrl) {
        return GrpcClients.create(GreeterGrpc.class, baseUrl);
    }
}

// call site
GreeterGrpc g = GreeterGrpc.of("https://api.example.com");
HelloRequest req = new HelloRequest();
req.name = "world";
g.sayHello(req, resp -> {
    if (resp.getResponseCode() == 200) {
        System.out.println(resp.getResponseData().message);
    }
});

Types

annotation GrpcClientMarks 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.
annotation ProtoEnumMarks a Java enum as a Protocol Buffers enum.
annotation ProtoFieldBinds a ProtoMessage field to a protobuf field tag.
annotation ProtoMessageMarks a POJO (or Java 17+ record) as a Protocol Buffers message.
annotation RpcBinds a method to a gRPC RPC: a GrpcClient interface method in an application or a backend, or a method of a backend @GrpcService.