[bv-dev] When is a method validated

Gerhard Petracek gerhard.petracek at gmail.com
Thu Mar 1 15:13:43 EST 2012


since it's possible to define the order of cdi interceptors via the std.
beans.xml config and there are a lot of very different valid use-cases, i
would prefer one default behaviour and the possibility to specify a custom
order via the std. cdi config.

regards,
gerhard



2012/2/28 Emmanuel Bernard <emmanuel at hibernate.org>

> I personally feel uneasy about having the behavior change depending on how
> visible annotations are to the client even though I understand the
> reasoning. As I said, interceptor messing around parameter and return
> values are not very common and one could clearly put interceptors not
> complying with the constraints under the programming error. I am reluctant
> to introduce an option to alter the behavior.
>
> That being said. Java EE 7 plans on making interceptors configuration
> generic. So it's likely that one person will be able to reorder its
> interceptors or even write its own.
>
> Emmanuel
>
> On 28 févr. 2012, at 00:28, Michael Nascimento wrote:
>
> > Ok, let's complicate matters a little bit:
> >
> > If a bean is exposed through an interface and therefore constraints
> > are applied to the implementation, obviously parameter validation
> > should happen right before invoking the method and return validation
> > should happen right after return. In this case, validation constraints
> > are completely opaque for the original caller and certainly they are
> > not part of the API.
> >
> > If a bean is exposed *directly* to the caller, constraints are part of
> > the API exposed to the caller. They are part of the contract pretty
> > much like possible thrown checked exceptions and all, so it would make
> > more sense to validate parameters right after the caller invokes it
> > and validate the return value right before delivering it to the
> > caller. Then, the API does what it says.
> >
> > Does this different behaviour sound complicated? Yes, but this is
> > technically the correct thing to do if you think about validation
> > being part of the API or not. As cumbersome as it seems, it is
> > possible to implement it using CDI since it allows one to get the
> > exact InjectionTarget and check for the API rule above. Should it be
> > done that way? That is open to discussion, but I am pretty sure other
> > people will reason it the way I just did.
> >
> > Regards,
> > Michael
> > _______________________________________________
> > beanvalidation-dev mailing list
> > beanvalidation-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>
>
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/beanvalidation-dev/attachments/20120301/3a4531af/attachment.html 


More information about the beanvalidation-dev mailing list