1

We're developing a service that uses the resteasy framework. It works fine with XML and json application/content-types. However, we need to use one more format: bson.

I installed the bson4jackson plugin, but I can't figure out how I should use it with resteasy. I understand that I have to implement a producer/consumer class, but I didn't find any examples.

Any advices/ideas to solve this problem?

gregwhitaker
  • 13,124
  • 7
  • 69
  • 78

1 Answers1

1

You need to implement a custom MessageBodyReader and MessageBodyWriter to handle the bson media type.

Reader:

@Provider
@Consumes("application/bson")
public class BsonMessageBodyReader implements MessageBodyReader {

}

Writer:

@Provider
@Produces("application/bson")
public class BsonMessageBodyWriter implements MessageBodyWriter {

}
gregwhitaker
  • 13,124
  • 7
  • 69
  • 78