0

I currently use ReloadableResourceBundleMessageSource from Spring as MessageSource in order to read internationalization messages.

The version of Spring I use is: 4.3.1.RELEASE

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>classpath:messages/messages</value>
        </list>
    </property>
    <property name="cacheSeconds" value="1" />
    <property name="defaultEncoding" value="UTF-8" />
</bean>

The thing is that I want to use PropertiesConfiguration (from Apache Commons Configuration 2) as a MessageSource. The problem I have is that both extend different classes. I would need to know if Apache Commons Configuration provides a ready-made MessageSource with PropertiesConfiguration or how to make a new MessageSource with this configuration.

The advantage of using this configuration is to have Variable Interpolation that is unavailable in Java's Properties class.

My question is based on this question, but with a twist because I don't use properties directly in my app, but through a message source provided by Spring and I don't want to change that code.

Sebastian D'Agostino
  • 1,575
  • 2
  • 27
  • 44
  • That interpolation is also provided by the `MessageSource`. And the `MessageSource` is for messages/translations not for properties. – M. Deinum May 09 '18 at 06:03
  • @M.Deinum Are you sure? I must be doing it wrong then. Could you provide me an example or a link? I tried to do something like this https://stackoverflow.com/questions/872272/how-to-reference-another-property-in-java-util-properties and failed. – Sebastian D'Agostino May 09 '18 at 13:01
  • It depends on what you want. As stated a `MessageSource` is for messages (i.e. I18N ) not for configuring your application for that you should use a `PropertyPlaceHolderConfigurer`. – M. Deinum May 09 '18 at 13:03

0 Answers0