I have managed to resolve the issue with a customization to the JAXBConverter.
I would suggest this change being considered for the main extension:
Current version:
@Override
public <T> float score(Representation source, Class<T> target,
Resource resource) {
float result = -1.0F;
if (source != null) {
if (source instanceof JaxbRepresentation<?>) {
result = 1.0F;
} else if (JaxbRepresentation.class.isAssignableFrom(target)
|| isJaxbRootElementClass(target)
|| JaxbRepresentation.class.isAssignableFrom(source
.getClass())) {
result = 1.0F;
}
}
return result;
}
Customized version:
@Override
public <T> float score(Representation source, Class<T> target,
Resource resource) {
float result = -1.0F;
if (source != null) {
if (source instanceof JaxbRepresentation<?>) {
result = 1.0F;
} else if (JaxbRepresentation.class.isAssignableFrom(target)
|| JaxbRepresentation.class.isAssignableFrom(source
.getClass())) {
result = 1.0F;
}
else if(isJaxbRootElementClass(target))
{
result = 0.7F;
}
}
return result;
}
When processing an incoming representation with the current version, if the
class you are translating to is XML annotated whatsoever it will always score a
1.0, making it difficult (if not impossible) for any other Converter to be used
based on the ordering.
This consideration was actually already made for the outgoing representation
processing:
// Allow for JAXB object to be used for JSON and other
// representations
result = 0.7F;
Which is from where I made the decision to use a 0.7F score. With this change,
the JacksonConverter wins when the Variant is VARIANT_JSON with a 0.8F. Some
consideration as to the exact score desired may be needed, I have not analyzed
any other Converters.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2938323