Class ProtobufHttpMessageConverter

  • All Implemented Interfaces:
    HttpMessageConverter<com.google.protobuf.Message>
    Direct Known Subclasses:
    ProtobufJsonFormatHttpMessageConverter

    public class ProtobufHttpMessageConverter
    extends AbstractHttpMessageConverter<com.google.protobuf.Message>
    An HttpMessageConverter that reads and writes com.google.protobuf.Messages using Google Protocol Buffers.

    To generate Message Java classes, you need to install the protoc binary.

    This converter supports by default "application/x-protobuf" and "text/plain" with the official "com.google.protobuf:protobuf-java" library. Other formats can be supported with one of the following additional libraries on the classpath:

    • "application/json", "application/xml", and "text/html" (write-only) with the "com.googlecode.protobuf-java-format:protobuf-java-format" third-party library
    • "application/json" with the official "com.google.protobuf:protobuf-java-util" for Protobuf 3 (see ProtobufJsonFormatHttpMessageConverter for a configurable variant)

    Requires Protobuf 2.6 or higher (and Protobuf Java Format 1.4 or higher for formatting). This converter will auto-adapt to Protobuf 3 and its default protobuf-java-util JSON format if the Protobuf 2 based protobuf-java-format isn't present; however, for more explicit JSON setup on Protobuf 3, consider ProtobufJsonFormatHttpMessageConverter.

    Since:
    4.1
    Author:
    Alex Antonov, Brian Clozel, Juergen Hoeller, Sebastien Deleuze
    See Also:
    FormatFactory, JsonFormat, ProtobufJsonFormatHttpMessageConverter