I am trying to produce output of a simple class annotated with JAXB
annotations that is also used for persisting to a MongoDB. Specifically
one of my elements is a Mongo ObjectId type. ObjectId is a class that
is Serializable but Jersey (or rather JAXB) does not produce any output
for this field. I'm wondering what approach I need to take to make this
output show up when I call my Resource. The bean is annotated as such:
@XmlRootElement("foo")
@XmlAccessorType(XmlAccessType.FIELD)
public class Foo {
@XmlElement(name = "id")
private ObjectId id;
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
}
So would a ContextResolver be necessary here to ensure the
ObjectId.toString() method is called? Or is there another way it is
recommended to produce output for an object I don't have access to
annotate with JAXB? This seems like a simple and common issue but I
can't seem to find the solution...probably looking in the wrong place.
Thanks for any pointers.