MessageBodyWriter/Reader's type should take precedence

From: Bill Burke <>
Date: Sat, 07 Feb 2009 00:21:07 -0500


I introduced a new YAML provider that does this:

@Produces({"text/yaml", "text/x-yaml", "application/x-yaml"})
public class YamlProvider implements MessageBodyWriter
    boolean isWritable(...)
        return true;

Basically it write any Java object out to YAML. The problem?

This screws up methods using StreamingOutput for example:

public StreamingOutput getYAML() {...}

Because of provider sorting rules, the YamlProvider will *ALWAYS* get
picked over the StreamingOutput provider because its @Produces is more
specific that StreamingOutput's provider (*/*).


Readers/Writers that are more type specific should always take precedence:

public class StreamingOutputProvider implements
MessageBodyWriter<StreamingOutput> {}

This provider takes precedence over the YamlProvider with the getYAML()
example because the returned object type matches the ParameterizedType
of the StreamingOutputProvider.

Bill Burke
JBoss, a division of Red Hat