jump to navigation

Spring Aggregating MessageSource March 26, 2010

Posted by Phill in General J2EE, Spring.
Tags: , , ,
comments closed

If you’ve ever worked on a modular project which needs to be internationalised, chances are you’ll have run into the requirement of combining messages from various different modules.

By that I mean, each module has its own message source, but you want them to be combined into one MessageSource. This could be required for various different reasons which I won’t go into here, but suffice it to say that this is possible with Spring.

I created an AggregatingMessageSource which would scan the ApplicationContext for instances of MessageSource. When a message was requested, it would search each one sequentially for the relevant message.

Anyway, if you need such a class, I have uploaded it to get you started. Obviously, customise it to your own needs: AggregatingMessageSource.java.