[hibernate-dev] Message-Templates from multiple JARs

Hardy Ferentschik hibernate at ferentschik.de
Wed Feb 17 20:38:30 EST 2010


On Tue, 16 Feb 2010 18:41:12 -0300, Gunnar Morling  
<gunnar.morling at googlemail.com> wrote:

> I agree with Max, I think there should be some way for packaging message
> bundles within components containing constraint annotations, while  
> offering
> the possibility to optionally override these with custom messages if
> required.
>
> With respect to large-scale enterprise apps, I guess it can become quite
> impractical to demand, that all component teams provide one single  
> message
> bundle. Also having to copy contents of message bundles from 3rd-party  
> libs
> containing constraint annotations to the local bundle could get somewhat
> tedious.
>
> Providing a custom MessageInterpolator might be viable, nevertheless I
> think, such a mechanism should work out of the box.

Well, having a simple configuration option is almost like "out of the box".
For most cases the default behavior will be good enough and for the few  
cases
a simple configuration option will do the trick.

> Not sure though, what the best solution here is. I also thought about
> merging the ValidationMessages.properties from different
> libraries/components (similar to what java.util.ServiceLoader does) into  
> one
> bundle, giving the contents from the local ValidationMessages.properties
> precedence. That way  components could provide message texts for their
> constraints (name clashes are possible but actually shouldn't happen, as
> message keys should be fully-qualified), while offering the possibility  
> to override these texts within the local bundle if required.

This could be one of the custom ResourceBundleLocator strategies we have
been talking about.

--Hardy



More information about the hibernate-dev mailing list