Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public Response postTweet(Tweet aTweet){
//Tweet is a custom domain object
public TweetReader implements MessageBodyReader<Tweet>{
public Tweet readFrom(Class<Tweet> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> headers, InputStream payload){
//use the InputStream (e.g. Tweet in form of JSON payload) and convert it into the domain representation of a Tweet
//which will then be injected into the postTweet method
Tweet domainObj = .... ;
return domainObj;
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType){
//use the contextual info - type, genericType and mediaType to determine if this message body reader can actually return the desired Java type
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment