<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> - I broke the TCK test suite :)</div><div> - 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 <<a href="mailto:emmanuel.bernard@JBOSS.COM">emmanuel.bernard@JBOSS.COM</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>Date:<span class="Apple-converted-space"> </span></b></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica"> June 15, 2009 23:10:33<span class="Apple-converted-space"> </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 <<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; 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<ACMEConfiguration> {
...
}</pre></span></div><div><br></div><div><br></div><div>Validation.byProvider() 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; ">/**
         * Build a <code>Configuration</code> for a particular provider implementation.
         * Optionally overrides the provider resolution strategy used to determine the provider.
         * <p/>
         * Used by applications targeting a specific provider programmatically.
         * <p/>
         * <pre>
         * ACMEConfiguration configuration =
         * Validation.byProvider(ACMEProvider.class)
         * .providerResolver( new MyResolverStrategy() )
         * .configure();
         * </pre>,
         * where <code>ACMEConfiguration</code> is the
         * <code>Configuration</code> sub interface uniquely identifying the
         * ACME Bean Validation provider. and ACMEProvider is the ValidationProvider
         * implementation of the ACME provider.
         *
         * @param providerType the <code>ValidationProvider</code> implementation type
         *
         * @return instance building a provider specific <code>Configuration</code>
         * sub interface implementation.
         */
        public static <T extends Configuration<T>, U extends ValidationProvider<T>>
                        ProviderSpecificBootstrap<T> byProvider(Class<U> 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.
* <p/>
* Implementations must have a public no-arg constructor. The construction of a provider
* should be as "lightweight" as possible.
*
* <code>T</code> represents the provider specific Configuration subclass
* which typically host provider's additional configuration methods.
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
public interface ValidationProvider<T extends Configuration<T>> {
        /**
         * Returns a Configuration instance implementing <code>T</code>,
         * the <code>Configuration</code> subinterface.
         * The returned Configuration instance must use the current provider (<code>this</code>)
         * to build the ValidatorFactory instance.
         * <p/>
         *
         * @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}
         * <p/>
         * The ValidationProviderResolver used by <code>Configuration</code>
         * is provided by <code>state</code>.
         * If null, the default ValidationProviderResolver is used.
         *
         * @param state bootstrap state
         *
         * @return Non specialized Configuration implementation
         */
        Configuration<?> createGenericConfiguration(BootstrapState state);
        /**
         * Build a ValidatorFactory using the current provider implementation. The
         * ValidatorFactory is assembled and follows the configuration passed
         * via ConfigurationState.
         * <p>
         * The returned ValidatorFactory is properly initialized and ready for use.
         * </p>
         *
         * @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>