<div>hi @ all,</div><div><br></div><div>imo we should also talk with other expert-groups about the basic idea.</div><div>e.g. the jsf-eg (i&#39;m going to propose group-validation triggered via command components (based on a feature of myfaces extval) and maybe they have additional ideas related to this topic.)</div>

<div><br></div><div>regards,</div><div>gerhard<br><br><br><br><div class="gmail_quote">2012/1/27 Hardy Ferentschik <span dir="ltr">&lt;<a href="mailto:hardy@hibernate.org">hardy@hibernate.org</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thanks Gunnar for the explanation. It made things much clearer (at least for me).<br>
Maybe my confusion was also caused by the fact that @ValidateGroups was so<br>
generically named. I don&#39;t think it really expresses its intend. Wouldn&#39;t something like<br>
@MethodValidated be better?<br>
<span class="HOEnZb"><font color="#888888"><br>
--Hardy<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Jan 26, 2012, at 9:29 PM, Gunnar Morling wrote:<br>
<br>
&gt; 2012/1/26 Hardy Ferentschik &lt;<a href="mailto:hardy@hibernate.org">hardy@hibernate.org</a>&gt;:<br>
&gt;<br>
&gt;&gt; On Jan 22, 2012, at 8:33 PM, Gunnar Morling wrote:<br>
&gt;&gt;&gt; Instead this should be task of technologies integrating the method<br>
&gt;&gt;&gt; validation feature to decide whether a validation is needed or not and<br>
&gt;&gt;&gt; if so delegate that validation to BV.<br>
&gt;&gt;<br>
&gt;&gt; Right. My understanding was that if method level validation is enabled in the integrating<br>
&gt;&gt; framework and method level annotations exist, validation gets triggered.<br>
&gt;<br>
&gt; Yepp, I think there are different interpretations of &quot;enabling method<br>
&gt; validation&quot; floating around which might cause some irritations. There<br>
&gt; are actually two &quot;levels&quot; of enablement IMO:<br>
&gt;<br>
&gt; * A system is generally able to make use of method validation by<br>
&gt; providing the required integration layer. Taking CDI for example,<br>
&gt; there would be a CDI method interceptor which is able to intercept<br>
&gt; method calls and invoke Validator#validateParameters() and/or<br>
&gt; Validator#validateReturnValue().<br>
&gt; * Based on that integration layer, method validation is actually<br>
&gt; enabled (or not) for given types. In other words instead of enabling<br>
&gt; method validation globally for all types/methods, I think often a more<br>
&gt; fine-grained configurability is required. Sticking to the CDI example,<br>
&gt; the types to perform method validation on, would be annotated with an<br>
&gt; interceptor binding annotation which causes the validation interceptor<br>
&gt; to kick in if methods on the annotated type are invoked. Taking Spring<br>
&gt; AOP as example, the types for which to perform method validation on<br>
&gt; could be specified using an advice with type name patterns,<br>
&gt; restrictions to certain packages etc.<br>
&gt;<br>
&gt;&gt;&gt; #2 Define an annotation such as @javax.validation.ValidateGroups within BV<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;       @ValidateGroups({Group1.class, Group2.class})<br>
&gt;&gt;&gt;       public class OrderService {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;               @NotNull<br>
&gt;&gt;&gt;               public Order placeOrder(@NotNull(groups=Group1.class) @Size(min=3,<br>
&gt;&gt;&gt; max=20) String customerCode, @NotNull Item item, @Min(1) int quantity)<br>
&gt;&gt;&gt; { //... }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;       }<br>
&gt;&gt;<br>
&gt;&gt; What would @ValidateGroups in this case do?<br>
&gt;<br>
&gt; @ValidateGroups would be the second &quot;enabler&quot; from the two above. That<br>
&gt; is, it controls that method validation shall be performed on the<br>
&gt; methods of OrderService by means of the validation interceptor<br>
&gt; provided by the given integration layer. It would also control which<br>
&gt; groups should be validated for methods invoked on the annotated type<br>
&gt; (here Group1 and Group2). It furthermore might control whether to<br>
&gt; perform a parameter or return value validation or both.<br>
&gt;<br>
&gt; This is comparable to declarative transaction control; there exists an<br>
&gt; interceptor which is able to begin/commit transactions. To which<br>
&gt; types/operations this interceptor applies can be controlled using an<br>
&gt; annotation such as @Transactional (or other means such as an XML<br>
&gt; config).<br>
&gt;<br>
&gt;&gt;&gt; #3 Don&#39;t define anything related in BV, leave that completely to integrators<br>
&gt;&gt;<br>
&gt;&gt; That is probably the solution I had in mind from the beginning. Seems still most reasonable to me.<br>
&gt;<br>
&gt; That&#39;s definitely an option, but it might cause a proliferation of the<br>
&gt; JEE platform. There are several potential integrators of method<br>
&gt; validation (I know at least about CDI and JAX-RS). They could all<br>
&gt; define their own variant of @ValidateGroups, but these would likely be<br>
&gt; very similar to each other. So another option is to define one<br>
&gt; standardized annotation for that purpose in BV which then can be used<br>
&gt; by all interested integrators. For instance<br>
&gt;<br>
&gt; * JAX-RS would check for that annotation on REST resource classes and<br>
&gt; would invoke j.v.Validator upon invocation of resource methods<br>
&gt; * CDI would define a CDI method interceptor and handle the annotation<br>
&gt; as interceptor binding annotation which causes the interceptor to kick<br>
&gt; in using the standard CDI mechanisms for interceptor handling<br>
&gt;<br>
&gt;&gt;&gt; Taking CDI for example, AFAIK the annotation would have to be annotated with the @InterceptorBinding meta annotation. I don&#39;t know whether/how it would be possible that we define the &quot;basic&quot; annotation, while integrators &quot;enrich&quot; it with the meta data they require.<br>


&gt;<br>
&gt; In between I had the chance to talk to Pete from the CDI EG. He<br>
&gt; confirmed that annotation types can programmatically be &quot;promoted&quot; to<br>
&gt; interceptor binding annotations. That means CDI could integrate with<br>
&gt; an annotation type defined in the BV API also if that type hasn&#39;t the<br>
&gt; @InterceptorBinding meta annotation (which it shouldn&#39;t IMO in order<br>
&gt; to avoid a compile dependency from BV to CDI).<br>
&gt;<br>
&gt; --Gunnar<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; beanvalidation-dev mailing list<br>
&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
<br>
<br>
_______________________________________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
</div></div></blockquote></div><br></div>