[hibernate-issues] [Hibernate-JIRA] Created: (BVAL-225) JSR303 1.1: support resource bundles in constraint annotation packages

Gabriele Del Prete (JIRA) noreply at atlassian.com
Thu Apr 7 06:12:59 EDT 2011


JSR303 1.1: support resource bundles in constraint annotation packages
----------------------------------------------------------------------

                 Key: BVAL-225
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-225
             Project: Bean Validation
          Issue Type: Improvement
    Affects Versions: 1.1
            Reporter: Gabriele Del Prete
         Attachments: ResourceBundleMessageInterpolator.java

(I published this same proposal also on the forum, and copying it here so that it does not get lost)

This is a proposal for the new version of JSR 303 (v1.1 ?).

The proposal is: modify the default message interpolation algorithm (section 4.3.1.1) so that the validation engine looks for a Resource Bundle called "ValidationMessages" in the constraint annotation's own package.

For example, when validating constraint annotation com.gdpcons.constraints.MustEqual, validator should also look for messages in a resource bundle called com.gdpcons.constraints.ValidationMessages.

The constraint annotation package ValidationMessages resource bundle should be checked after the "user" ValidationMessages resource bundle, but before the BeanValidation provider's own private ValidationMessages resource bundle, so as to allow users to override the string provided by the constraint annotation resource bundle.

This would allow people to write redistributable collections of constraint annotations, since as of today it's not possible to use multiple ValidationMessages resource bundles files (one will override all the others in the classpath); and it would still allow users to override the provided messages just by a new definition for the message key in their own ValidationMessages resource bundle.

I've written an example implementation, by modifying Hibernate Validator's own ResourceBundleMessageInterpolator. It seams to work without side effects, and is a very straightforward implementation. 

See it attached to this issue.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list