On Wed, Mar 24, 2010 at 9:40 AM, Chris Carrier <ctcarrier_at_gmail.com> wrote:
> I'm not very familiar with the Java bean validation stuff. I assume
> you're referring to JSR 303 like the Hibernate Validator:
Yes. I have used hibernate validator itself, which fortunately is
light on dependencies (need not use anything from hibernate proper
afaik).
> http://docs.jboss.org/hibernate/stable/validator/reference/en/html_single/
>
> How does this integrate with JAX-RS/Jersey? If I annotate my POJO's
> with Hibernate Validation annotations will they automagically be
> validated by Jersey? Do I still have to manually add some step to
> trigger validation? I would really like to perform validation in a
> more standard/less obtrusive way but at this point I'm pretty much
> using a bunch of null checks after marshalling.
>
> Any more info on this would be greatly appreciated.
I don't think there is automatic integration (some might be nice); I
just explicitly validated beans, in my cases just requests. Since I
did explicit data binding (for more explicit logging, error handling)
it was just one small step. Validation itself is a one-liner so it
sort of naturally fits after reading data as object, or before writing
object as data.
I wish I had sample code at hand (it was done for a company, not open
source, so I don't have exact piece to share).
Paul and others may be able to suggest more generic approach (a
filter?) to use. Actually, I wonder if one could override response
builder to do this right before serialization gets called.
-+ Tatu +-