<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hardy,<div>Wish #1 realized. But this has consequences:</div><div>&nbsp;- I broke the TCK test suite :)</div><div>&nbsp;- you are officially responsible to review the spec / javadoc changes (see attached email with spec diff)<br><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>From: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Emmanuel Bernard &lt;<a href="mailto:emmanuel.bernard@JBOSS.COM">emmanuel.bernard@JBOSS.COM</a>&gt;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>Date:<span class="Apple-converted-space">&nbsp;</span></b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica"> June 15, 2009 23:10:33<span class="Apple-converted-space">&nbsp; </span>EDT</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>To: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica"><a href="mailto:JSR-303-EG@JCP.ORG">JSR-303-EG@JCP.ORG</a></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>Subject: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica"><b>Validation.byProvider() revisited</b></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><b>Reply-To: </b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Java Community Process JSR #303 Expert List &lt;<a href="mailto:JSR-303-EG@JCP.ORG">JSR-303-EG@JCP.ORG</a>&gt;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div> </div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I never liked the idea that byProvider() was taking a Configuration subclass and not the actual ValidationProvider class.<div>This is now fixed using some additional generics magic. It has also the nice side effect of simplifying the contract between the bootstrap module and the providers.</div><div><br></div><div>In a nutshell, instead of</div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 14px; "><pre class="programlisting" style="font-family: monospace; font-size: 14px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); background-color: rgb(244, 244, 244); width: auto; position: static; z-index: auto; ">ValidatorFactory factory = Validation
       .byProvider( ACMEConfiguration.class )  //chose a specific provider
       .configure()
          .messageInterpolator( new ContainerMessageInterpolator() ) //default configuration option
          .addConstraint(Address.class, customConstraintDescriptor) //ACME specific method
          .buildValidatorFactory();</pre></span></div><div><br></div><div>we have</div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 14px; "><pre class="programlisting" style="font-family: monospace; font-size: 14px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); background-color: rgb(244, 244, 244); width: auto; position: static; z-index: auto; ">ValidatorFactory factory = Validation
       .byProvider( ACMEProvider.class )  //chose a specific provider
       .configure()
          .messageInterpolator( new ContainerMessageInterpolator() ) //default configuration option
          .addConstraint(Address.class, customConstraintDescriptor) //ACME specific method
          .buildValidatorFactory();</pre></span></div><div><br></div><div>The ACME provider becomes</div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 14px; "><pre class="programlisting" style="font-family: monospace; font-size: 14px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); background-color: rgb(244, 244, 244); width: auto; position: static; z-index: auto; ">/**
 * ACME validation provider
 * Note how ACMEConfiguration and ACMEProvider are linked together 
 * via the generic parameter.
 */
public class ACMEProvider implements ValidationProvider&lt;ACMEConfiguration&gt; {
    ...
}</pre></span></div><div><br></div><div><br></div><div>Validation.byProvider() now is&nbsp;</div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 14px; "><pre class="programlisting" style="font-family: monospace; font-size: 14px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); background-color: rgb(244, 244, 244); width: auto; position: static; z-index: auto; ">/**
         * Build a &lt;code&gt;Configuration&lt;/code&gt; for a particular provider implementation.
         * Optionally overrides the provider resolution strategy used to determine the provider.
         * &lt;p/&gt;
         * Used by applications targeting a specific provider programmatically.
         * &lt;p/&gt;
         * &lt;pre&gt;
         * ACMEConfiguration configuration =
         *     Validation.byProvider(ACMEProvider.class)
         *             .providerResolver( new MyResolverStrategy() )
         *             .configure();
         * &lt;/pre&gt;,
         * where &lt;code&gt;ACMEConfiguration&lt;/code&gt; is the
         * &lt;code&gt;Configuration&lt;/code&gt; sub interface uniquely identifying the
         * ACME Bean Validation provider. and ACMEProvider is the ValidationProvider
         * implementation of the ACME provider.
         *
         * @param providerType the &lt;code&gt;ValidationProvider&lt;/code&gt; implementation type
         *
         * @return instance building a provider specific &lt;code&gt;Configuration&lt;/code&gt;
         * sub interface implementation.
         */
        public static &lt;T extends Configuration&lt;T&gt;, U extends ValidationProvider&lt;T&gt;&gt;
                        ProviderSpecificBootstrap&lt;T&gt; byProvider(Class&lt;U&gt; providerType) {
                [...]
        }</pre></span></div><div><br></div><div>ValidationProvider now is</div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 14px; "><pre class="programlisting" style="font-family: monospace; font-size: 14px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); background-color: rgb(244, 244, 244); width: auto; position: static; z-index: auto; ">package javax.validation.spi;

/**
 * Contract between the validation bootstrap mechanism and the provider engine.
 * &lt;p/&gt;
 * Implementations must have a public no-arg constructor. The construction of a provider
 * should be as "lightweight" as possible.
 *
 * &lt;code&gt;T&lt;/code&gt; represents the provider specific Configuration subclass
 * which typically host provider's additional configuration methods.
 *
 * @author Emmanuel Bernard
 * @author Hardy Ferentschik
 */
public interface ValidationProvider&lt;T extends Configuration&lt;T&gt;&gt; {

        /**
         * Returns a Configuration instance implementing &lt;code&gt;T&lt;/code&gt;,
         * the &lt;code&gt;Configuration&lt;/code&gt; subinterface.
         * The returned Configuration instance must use the current provider (&lt;code&gt;this&lt;/code&gt;)
         * to build the ValidatorFactory instance.
         * &lt;p/&gt;
         *
         * @param state bootstrap state
         *
         * @return specific Configuration implementation
         */
        T createSpecializedConfiguration(BootstrapState state);

        /**
         * Returns a Configuration instance. This instance is not bound to
         * use the current provider. The choice of provider follows the algorithm described
         * in {@link javax.validation.Configuration}
         * &lt;p/&gt;
         * The ValidationProviderResolver used by &lt;code&gt;Configuration&lt;/code&gt;
         * is provided by &lt;code&gt;state&lt;/code&gt;.
         * If null, the default ValidationProviderResolver is used.
         *
         * @param state bootstrap state
         *
         * @return Non specialized Configuration implementation
         */
        Configuration&lt;?&gt; createGenericConfiguration(BootstrapState state);

        /**
         * Build a ValidatorFactory using the current provider implementation. The
         * ValidatorFactory is assembled and follows the configuration passed
         * via ConfigurationState.
         * &lt;p&gt;
         * The returned ValidatorFactory is properly initialized and ready for use.
         * &lt;/p&gt;
         *
         * @param configurationState the configuration descriptor
         *
         * @return the instanciated ValidatorFactory
         * @throws javax.validation.ValidationException if the ValidatorFactory cannot be built
         */
        ValidatorFactory buildValidatorFactory(ConfigurationState configurationState);
}</pre></span></div><div><br></div><div>esp, we no longer have isSuitable.</div><div><br></div><div><br></div><div>Any objection? The diff for the spec is attached</div><div><a href="http://people.redhat.com/~ebernard/validation/#bootstrapping">http://people.redhat.com/~ebernard/validation/#bootstrapping</a></div><div><br></div><div><br></div><div></div></div></blockquote></div></div></body></html>