Class InvernoGrpcProtocPlugin

java.lang.Object
io.inverno.tool.grpc.protocplugin.InvernoGrpcProtocPlugin

public class InvernoGrpcProtocPlugin extends Object

A protoc plugin used to generate Inverno specific gRPC client and/or server classes.

The command accepts two options:

  • --client: tells the plugin to generate client classes
  • --server: tells the plugin to generate server classes

If none of the above is specified, the plugin generates no classes.

The command parses the code generator request from the standard input by default (i.e. System.in) as expected when invoked inside protoc.exe as follows:


 $ protoc.exe --plugin=protoc-gen-grpc=invernoGrpcProtocPlugin.sh --grpc_out=target/generated-sources/protobuf/java file.proto
 

In above command line invernoGrpcProtocPlugin.sh is an executable script invoking the plugin with the right arguments. For instance:


 #!/bin/sh
 
 java -jar inverno-grpc-protoc-plugin.jar --server --client "@$"
 

It also possible to specify the path to a dump on the command line and execute the command in standalone:


 $ java -jar inverno-grpc-protoc-plugin.jar --server --client path/to/dump
 

The class also exposes several methods to create InvernoGrpcGenerator instances for generating client and/or server from raw descriptors.

Since:
1.9
Author:
Jeremy Kuhn
  • Constructor Details

    • InvernoGrpcProtocPlugin

      public InvernoGrpcProtocPlugin()
  • Method Details

    • main

      public static void main(String[] args)

      Executes the protoc plugin.

      Parameters:
      args - the command line arguments
    • generator

      public static InvernoGrpcGenerator generator()

      Creates generator that generates both client and server classes.

      Returns:
      a generator that generates both client and server
    • clientGenerator

      public static InvernoGrpcGenerator clientGenerator()

      Creates generator that generates client classes only.

      Returns:
      a generator that generates client
    • serverGenerator

      public static InvernoGrpcGenerator serverGenerator()

      Creates generator that generates server classes only.

      Returns:
      a generator that generates server