title: Combining Google proto buffers with Jersey/JAX-RS
body: <p>Currently I have a RESTful web service with endpoints that are exposed via Jersey/JAX-RS:</p>
  
  <pre><code>@Path("/widgets")
  public class WidgetResource {
      @GET
      List&lt;Widget&gt; getAllWidgets() {
          // gets Widgets somehow
      }
  
      @POST
      Widget save(Widget w) {
          // Save widget and return it
      }
  }
  </code></pre>
  
  <p>I use Jackson for serializing/deserializing my POJOs into JSON, and my service both responds to and sends back my POJOs as <code>application/json</code>.</p>
  
  <p>I am now looking to possibly use Google protocol buffers (or an equivalent technology) to help compress/optimize the communication between client and service, as JSON/text is pretty bulky/wasteful.</p>
  
  <p>In reality, I have a large backend that consists of a "microservice" architecture; dozens of REST services communicating with each other; this is why I'm looking to optimize the the messages sent backk and forth between all of them.</p>
  
  <p>So I ask: is it possible to still have Jersey/JAX-RS serve up my service endpoints, but to gut out the Jackson/JSON stuff and replace it with Google protocol buffers? If so, what might this code look like?</p>