On 18/09/13 19:44, David Hay wrote:
I have switched some of our REST methods to receive objects (via JSON)
rather than form params.
What is the suggested pattern to prevent invalid objects being received? I
assume that the default constructor is called followed by setters on the
object?
If you use CXF JSONProvider then you can pass it a list of XSD schema
locations (schemaLocations property), this works because the actual
object population is driven by JAXB.
Or you can register a custom XMLStreamReader too and do the custom
validation of the data reported by Jettison, I can provider more info if
your are interested.
You can also register a custom MessageBodyReader which simply delegates
to your chosen JSON provider (Jackson, etc), and validates the object in
its readFrom method, after the actual provider creates it
Sergey
cheers,
David
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com